<!DOCTYPE html>
<title>Document#fullscreenElement</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<script>
async_test(function(t)
{
    var div = document.querySelector("div");

    document.onfullscreenchange = t.step_func(function()
    {
        assert_equals(document.fullscreenElement, div, "fullscreenElement before exitFullscreen()");
        document.exitFullscreen();
        assert_equals(document.fullscreenElement, div, "fullscreenElement after exitFullscreen()");

        document.onfullscreenchange = t.step_func(function()
        {
            assert_equals(document.fullscreenElement, null, "fullscreenElement after exiting fullscreen");
            t.done();
        });
    });

    trusted_click(t, function()
    {
        assert_equals(document.fullscreenElement, null, "fullscreenElement before requestFullscreen()");
        div.requestFullscreen();
        assert_equals(document.fullscreenElement, null, "fullscreenElement after requestFullscreen()");
    }, document.body);
});
</script>
